<script setup>
import { ref,reactive, nextTick,onActivated,getCurrentInstance,onMounted, watch  } from 'vue'; 
import { useRoute,useRouter } from 'vue-router';
import { managementPlatform } from '@/api/ExtensionManage/index.js'
import { exportFile } from '@/utils/common.js';

const formInline = ref([
  {
    type: "input",
    prop: "transNo",
    placeholder: "流水号",
    label: "",
    model: "",
    minwidth: 260
  },
  {
    type: "input",
    prop: "memberQueryCondition",
    placeholder: "推广会员姓名/手机号",
    label: "",
    model: "",
    minwidth: 260
  },
])

const btnLefts = ref([
  {
    label: "导出",
    plain: false,
    type: "primary",
    show: true,
    plain: true,
    img: new URL("@/assets/icon/btn-export.png", import.meta.url),
    style: "border-color:#0C268C;color:#0C268C",
    click: async () => {
      const loading = ElLoading.service({
        lock: true,
        text: '导出中',
        background: 'rgba(255, 255, 255, 0.7)',
      })
      try {
        await exportFile(`/jy-member/mgmt/member/referrer/withdrawalRecordExport`, 'post', `提现记录`, {}, searchData.value)
        loading.close()
      } catch (e) {
        loading.close()
      }
    }
  },
])

const btnRights = ref([

])

const tableConfig = ref([
  {
    prop: "transNo",
    label: "流水号",
  },
  {
    prop: "amount",
    label: "提现金额（元）",
  },
  {
    prop: "memberName",
    label: "推广会员姓名",
  },
  {
    prop: "memberPhone",
    label: "推广会员手机号",
  },
  {
    prop: "settleTime",
    label: "提现时间",
  },
]);

const seachTable = ref(null);
const tableLoading = ref(false)
const totalPage = ref(0)
const tableData = ref([]);
const searchData = ref({})

const handlerSearch = async (formInline)=>{
    tableLoading.value = true;
    try{
        let data = {
            ...formInline
        }
        searchData.value = data
        const res = await managementPlatform(data)
        // console.log(res,'res');
        totalPage.value = res.total || 0;
        tableData.value = res.records || [];
        tableLoading.value = false;
    }catch(e){
        tableLoading.value = false;
    }
}
</script>

<template>
  <div class="page-content">
    <SeachTable :tableType="1" ref="seachTable" :forms="formInline" :btnLefts="btnLefts" :btnRights="btnRights"
      :tableLoading="tableLoading" :tableConfig="tableConfig" :tableData="tableData" :totalPage="totalPage"
      @handlerSearch="handlerSearch">
    </SeachTable>
  </div>
</template>